#include "welcome.h"
#include "app_controller.h"
#include <stdio.h>


void create_welcome_screen(void)
{
    
    lv_obj_t *ui_Screen1 = lv_scr_act();
    lv_obj_clean(ui_Screen1);
    lv_obj_clear_flag(ui_Screen1, LV_OBJ_FLAG_SCROLLABLE);      /// Flags
    lv_obj_set_style_bg_color(ui_Screen1, lv_color_hex(0x0000FF), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui_Screen1, 180, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_bg_grad_dir(ui_Screen1, LV_GRAD_DIR_HOR, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_border_width(ui_Screen1, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_text_align(ui_Screen1, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);

    //创建欢迎语使用该系统
    //使用textarea文本框上限更高
    lv_obj_t* ui_TextArea1 = lv_textarea_create(ui_Screen1);
    lv_obj_set_width(ui_TextArea1, 773);
    lv_obj_set_height(ui_TextArea1, 70);
    lv_obj_set_x(ui_TextArea1, -14);
    lv_obj_set_y(ui_TextArea1, -37);
    lv_obj_set_align(ui_TextArea1, LV_ALIGN_CENTER);

    lv_textarea_set_text(ui_TextArea1, "welcome rk3568 sys_monitor");
    lv_textarea_set_placeholder_text(ui_TextArea1, "Placeholder...");
    lv_obj_clear_flag(ui_TextArea1, LV_OBJ_FLAG_CLICKABLE);      /// Flags
    lv_obj_set_style_text_color(ui_TextArea1, lv_color_hex(0x808080), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_text_opa(ui_TextArea1, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_text_align(ui_TextArea1, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);

    lv_obj_set_style_text_font(ui_TextArea1, &lv_font_montserrat_48, LV_PART_MAIN | LV_STATE_DEFAULT);
    
    lv_obj_set_style_bg_color(ui_TextArea1, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
    
    lv_obj_set_style_bg_opa(ui_TextArea1, 0, LV_PART_MAIN | LV_STATE_DEFAULT);

    lv_obj_set_style_border_width(ui_TextArea1, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_pad_left(ui_TextArea1, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
   
    lv_obj_set_style_pad_right(ui_TextArea1, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_pad_top(ui_TextArea1, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_pad_bottom(ui_TextArea1, 0, LV_PART_MAIN | LV_STATE_DEFAULT);


    //创建按钮
    lv_obj_t * ui_Button1 = lv_btn_create(ui_Screen1);
    lv_obj_set_width(ui_Button1, 331);
    lv_obj_set_height(ui_Button1, 87);
    lv_obj_set_x(ui_Button1, -35);
    lv_obj_set_y(ui_Button1, 140);
    lv_obj_set_align(ui_Button1, LV_ALIGN_CENTER);
    lv_obj_set_flex_flow(ui_Button1, LV_FLEX_FLOW_ROW);
    lv_obj_set_flex_align(ui_Button1, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START);
    lv_obj_add_flag(ui_Button1, LV_OBJ_FLAG_SCROLL_ON_FOCUS);     /// Flags
    lv_obj_clear_flag(ui_Button1, LV_OBJ_FLAG_SCROLLABLE);      /// Flags
    //创建回调函数进入下一个界面
    
    //创建按钮上的标签，点击进入该测试系统
    lv_obj_t * ui_Label = lv_label_create(ui_Button1);
    lv_obj_set_width(ui_Label, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_Label, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_Label, 20);
    lv_obj_set_y(ui_Label, 2);
    lv_obj_set_align(ui_Label, LV_ALIGN_CENTER);
    lv_label_set_text(ui_Label, "click enter");
    lv_obj_set_style_text_align(ui_Label, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);

    lv_obj_set_style_text_font(ui_Label, &lv_font_montserrat_48, LV_PART_MAIN | LV_STATE_DEFAULT);


    lv_obj_add_event_cb(ui_Button1,go_to_dashboard,LV_EVENT_ALL,NULL);
}
